package com.zhangyanqiang.rabbitmqdemo.mq.consumer;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Map;

/**
 * @author zhangyanqiang
 * @date 2020/4/19
 **/
@Component
public class ReceiveMessageConsumer {



    @RabbitListener(queues = "directQueue")
    public void processDirect1Message(Map message){

        System.out.println("receiving message 1"+ message);

    }

    //如果需要测试 队列长度限制需要把 消费者注释 让消息堆积在队列
//    @RabbitListener(queues = "limitQueue")
//    public void processLimitQueueMessage(Map message){
//
//        System.out.println("receiving limit queue message "+ message);
//
//    }

    @RabbitListener(queues = "receiveTTLQueue")
    public void processReceiveTTLQueueMessage(Map message){


        System.out.println("receiveTTLQueue receiving message 2"+ message+ " "+ Calendar.getInstance().getTime());

    }

    @RabbitListener(queues = "exclusiveTrueQueue")
    public void processExclusiveTrue1Message(Map message){

        System.out.println("receiving message1 "+ message);

    }

    @RabbitListener(queues = "exclusiveFalseQueue")
    public void processExclusiveFalseMessage(Map message){

        System.out.println("receiving message "+ message);

    }
    @RabbitListener(queues = "exclusiveTrueQueue")
    public void processExclusiveTrue2Message(Map message){

        System.out.println("receiving message2 "+ message);

    }

}
